package net.logax.games.chase.map;

import net.logax.games.chase.map.Map.MapFragment;

public class MapTestRenderer {
	public void render(Map.MapFragment[][][] mapArray, int mapSizeX, int mapSizeY, int mapSizeZ) {
		int currentX = -1;
		int currentY = -1;
		int currentZ = -1;
		try {

			for (int z = 0; z < mapSizeZ; z++) {
				for (int y = mapSizeY - 1; y >= 0; y--) {
					boolean isEmptyLine = true;
					for (int x = 0; x < mapSizeX; x++) {
						Map.MapFragment fragment = mapArray[x][y][z];
						if (!MapFragment.EMPTY.equals(fragment)) {
							isEmptyLine = false;
						}
					}
					if (!isEmptyLine) {

						for (int x = 0; x < mapSizeX; x++) {
							currentX = x;
							currentY = y;
							currentZ = z;
							Map.MapFragment fragment = mapArray[x][y][z];
							switch (fragment) {
							case EMPTY:
								System.out.print(".");
								break;
							case START:
								System.out.print("S");
								break;
							case CURVE_X_Y:
								System.out.print("└");
								break;
							case CURVE_NX_Y:
								System.out.print("┘");
								break;
							case CURVE_X_NY:
								System.out.print("┌");
								break;
							case CURVE_NX_NY:
								System.out.print("┐");
								break;
							case CORRIDOR_Y:
								System.out.print("│");
								break;
							case CORRIDOR_X:
								System.out.print("─");
								break;
							case DEAD_END_NX:
								System.out.print("╴");
								break;
							case DEAD_END_NY:
								System.out.print("╷");
								break;
							case DEAD_END_Y:
								System.out.print("╵");
								break;
							case DEAD_END_X:
								System.out.print("╶");
								break;
							case T_CROSSING_NY:
								System.out.print("┬");
								break;
							case T_CROSSING_X:
								System.out.print("├");
								break;
							case T_CROSSING_NX:

								System.out.print("┤");
								break;
							case T_CROSSING_Y:
								System.out.print("┴");
								break;
							case CROSSING:
								System.out.print("┼");
								break;
							default:
								System.out.print("?");
							}
						}
						System.out.println("");
					}
				}
				System.out.println("- - - Etage: " + z + " - - -");
			}
		} catch (ArrayIndexOutOfBoundsException ex) {
			System.out.println("ArrayIndexOutOfBounds, x='" + currentX + "', y='" + currentY + "', z='" + currentZ + "'");
		}
	}
}
